# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=cargo-deny
pkgver=0.16.1
pkgrel=1
pkgdesc="Cargo plugin for linting your dependencies"
url="https://github.com/EmbarkStudios/cargo-deny"
# 32-bits: tests fail on 32bit https://github.com/EmbarkStudios/cargo-deny/issues/540
# s390x: tests fail due to different cargo index hash
arch="all !x86 !armv7 !armhf !s390x"
license="MIT OR Apache-2.0"
makedepends="
	cargo
	cargo-auditable
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/EmbarkStudios/cargo-deny/archive/refs/tags/$pkgver.tar.gz"
options="net"

prepare() {
	default_prepare
	# remove upstream's compile flags for musl target
	rm -r .cargo/
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	# These tests require the advisory repos to be cloned via git
	cargo test --frozen -- \
		--skip detects_unmaintained \
		--skip detects_unsound \
		--skip detects_vulnerabilities \
		--skip downgrades_lint_levels \
		--skip fails_on_stale_advisory_database \
		--skip fetches_with_git \
		--skip fetches_with_gix \
		--skip warns_on_ignored_and_withdrawn \
		--skip warns_on_index_failures
}

package() {
	install -Dm 755 target/release/cargo-deny "$pkgdir"/usr/bin/cargo-deny

	for l in APACHE MIT
	do
		install -Dm 644 LICENSE-"$l" "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE-"$l"
	done
}

sha512sums="
3801dda508b64cb94ea2b265f52220760f66075396ae3771bcb09e24389d595c2bd29a1f3d3a833e117b663526859e99c14763eb4b8ca75490b6470b5fb3b193  cargo-deny-0.16.1.tar.gz
"
